package com.elder.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.elder.business.domain.SuddenRecord;
import com.elder.business.domain.SuddenRecordDTO;
import com.elder.business.service.ISuddenRecordService;
import com.elder.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elder.common.annotation.Log;
import com.elder.common.core.controller.BaseController;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.enums.BusinessType;
import com.elder.common.utils.poi.ExcelUtil;
import com.elder.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author elder
 * @date 2024-03-20
 */
@RestController
@RequestMapping("/system/record")
public class SuddenRecordController extends BaseController
{
    @Autowired
    private ISuddenRecordService suddenRecordService;

    /**
     * 查询【请填写功能名称】列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(String elderName,String startTime,String endTime ,Integer pageNum,Integer pageSize)
    {
        return suddenRecordService.selectSuddenRecordList(elderName,startTime,endTime,pageNum,pageSize);
    }


    /**
     * 获取【请填写功能名称】详细信息
     */
    @Anonymous
    @GetMapping(value = "/{suddenId}")
    public AjaxResult getInfo(@PathVariable("suddenId") Long suddenId)
    {
        return success(suddenRecordService.selectSuddenRecordBySuddenId(suddenId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @Anonymous
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SuddenRecordDTO suddenRecord)
    {
        return toAjax(suddenRecordService.insertSuddenRecord(suddenRecord));
    }

    /**
     * 修改【请填写功能名称】
     */
    @Anonymous
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SuddenRecordDTO suddenRecord)
    {
        return toAjax(suddenRecordService.updateSuddenRecord(suddenRecord));
    }

    /**
     * 删除【请填写功能名称】
     */
    @Anonymous
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{suddenIds}")
    public AjaxResult remove(@PathVariable Long[] suddenIds)
    {
        return toAjax(suddenRecordService.deleteSuddenRecordBySuddenIds(suddenIds));
    }
}
